##! /bin/bash
#! bash
#
#  $Id: runem.sh 3 2010-05-27 16:25:49Z alistair.mills@btinternet.com $
#
. ./defines.sh
for table in table.txt
do
     ./dates.sh           $table
  if [ "$format_2008" == "true" ]
  then
     echo  ' 01/20 > ' building the database categories import file for the categories tables
    ./to_db_categories.sh categories.csv
     echo  ' 02/20 > ' building the database months import file for the months table
    ./to_db_months.sh months.csv
     echo  ' 03/20 > ' building the database translators import file for the translators table
    ./to_db_translators.sh translators.csv
     echo  ' 04/20 > ' building the translated documents
     ./files.sh           $table
     echo  ' 05/20 > ' building the index of the translated documents
    ./traduit.sh          $table index.html
     echo  ' 06/20 > ' building the index of the all of the available documents
    ./a_traduire.sh       $table traductions.html
     echo  ' 07/20 > ' building the database contents import file
    ./to_db_import.sh     $table contents.csv
     echo  ' 08/20 > ' building the statistics index and its database import file
    ./stats.sh            $table stats.html statistics.csv
     echo  ' 09/20 > ' building the database paragraphs import file for the English translations
    ./to_db_paragraphs.sh $table paras_en.csv english
     echo  ' 10/20 > ' building the database paragraphs import file for the French originals
    ./to_db_paragraphs.sh $table paras_fr.csv french
  fi
  if [ "$format_2010" == "true" ]
  then
     echo  ' 11/20 > ' building the SQL and CSV     tblCategory files
     ./to_category.sh            tblCategory.sql    tblCategory.csv
     echo  ' 12/20 > ' building the SQL and CSV     tblTranslator file
     ./to_translator.sh          tblTranslator.sql  tblTranslator.csv
     echo  ' 13/20 > ' building the SQL and CSV     tblMonth file
     ./to_month.sh               tblMonth.sql       tblMonth.csv
     echo  ' 14/20 > ' building the SQL and CSV     tblArticle files
     ./to_article.sh $table      tblArticle.sql     tblArticle.csv
     echo  ' 15/20 > ' building the SQL and CSV     tblParagraph files
    ./to_paragraph.sh $table     tblParagraph.sql   tblParagraph.csv
    OUTPUT=tblAll
    echo  ' 16/20 > ' building the SQL and CSV $OUTPUT files
    [ -f $OUTPUT.sql  ] && rm $OUTPUT.sql ; touch $OUTPUT.sql
    [ -f $OUTPUT.csv  ] && rm $OUTPUT.csv ; touch $OUTPUT.csv
    for i in Category Translator Month Article Paragraph
    do
      cat tbl$i.sql >> $OUTPUT.sql
      cat tbl$i.csv >> $OUTPUT.csv
    done
 fi
done
#
# the end
#
